import 'dart:core';

class CommentedNews {
  String newsId;
  String time;
  String source;
  String type;
  String title;
  String headerImage;
  String content;
  String comment;
  String commentTime;

  CommentedNews(
    this.newsId,
    this.time,
    this.source,
    this.type,
    this.title,
    this.headerImage,
    this.content,
    this.comment,
    this.commentTime,
  );

  static CommentedNews fromMap(Map<String, dynamic> map) {
    String comment = map['comment'];
    if (comment.length > 9) {
      comment = comment.substring(0, 7) + "...";
    }
    return CommentedNews(
        map['newsId'].toString(),
        map['time'].toString().substring(0, 10),
        map['source'],
        map['type'],
        map['title'],
        map['headerImage'],
        map['content'],
        comment,
        map['commentTime']);
  }
}
